﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Corporation.Product;

public partial class Member_ProType_ProTypeEdit : nspBase.MemberBasePge
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CheckCookies())
        {
            Response.Redirect("../../login/login.aspx");
            return;
        }
        else
        {
            if (!IsPostBack)
            {
                Bind();
            }
        }

    }
    private void Bind()
    {
        int id = 0;
        if (Request.QueryString["ID"] != null)
        {
            id = int.Parse(Request.QueryString["ID"].ToString());
        }
        TProType TProType = new RProType().GateItem(id);
        if (TProType != null)
        {
            txtOrder.Text = TProType.Sequence.ToString();
            txtTitle.Text = TProType.Name;
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            int id = 0;
            if (Request.QueryString["ID"] != null)
            {
                id = int.Parse(Request.QueryString["ID"].ToString());
            }
            RProType rtype = new RProType();
            TProType TType = new RProType().GateItem(id);
            TType.Name = txtTitle.Text;
            TType.Sequence = int.Parse(txtOrder.Text);
            rtype.Update(TType);
            ShowMessage("自定义分类信息修改成功！", "ProType/ProTypeList.aspx");
        }
        catch (Exception ex)
        {
            ShowMessage("自定义分类信息修改失败！", "ProType/ProTypeList.aspx");
        }
    }

    protected void btnBace_Click(object sender, EventArgs e)
    {
        Response.Write("<script> window.location.href='ProTypeList.aspx'</script>");
    }
}
